<template>
	<view class="container">
		<view class="header-box" :style="{ height: height + 'px', paddingTop: top + 'px' }">
			<view class="header-info">
				<tui-icon name="arrowleft" @tap="goBack" color="#333333" size="25" bold="true"></tui-icon>
				<view class="header-name">更多</view>
			</view>
		</view>
		<view class="search-container">
			<view class="search-box">
				<image src="/static/images/company/search.svg"></image>
				<input style="width: 100%" type="text" v-model="searchKey" placeholder="搜索职位" placeholder-class="search-holder" />
			</view>
			<view class="search-btn" @tap="search">搜索</view>
		</view>
		<!-- 薪资待遇 -->
		<view class="xinzi-box" v-for="item in DataList">
			<view class="xinziinfo-header">
				<view class="xinzi-BT">
					{{ item.GangweiM }}
				</view>
				<view class="right-box" style="font-size: 24rpx">{{ item.peopleCount }}人上传</view>
			</view>
			<view class="Line-info">薪资:{{ item.LowXinzi * 1000 }}~{{ item.MaxXinzi * 1000 }}</view>
			<view class="Line-info">工作年限:{{ item.MinNianFenJianGe }}~{{ item.MaxNianFenJianGe }}年</view>
		</view>
	</view>
	
</template>

<script>
export default {
	data() {
		return {
			Islogin: this.Microi.IsLogin(),
			CurrentUser: this.Microi.GetCurrentUser(),
			startTime: 0,
			DataList: [],
			options: {},
			height: 64, //header高度
			top: 26, //标题图标距离顶部距离
			scrollH: 0, //滚动总高度
			searchKey: '',
			page: 1,
			noData: false
		};
	},
	mounted() {
		let obj = {};
		// #ifdef MP-WEIXIN
		obj = wx.getMenuButtonBoundingClientRect();
		// #endif
		// #ifdef MP-BAIDU
		obj = swan.getMenuButtonBoundingClientRect();
		// #endif
		// #ifdef MP-ALIPAY
		my.hideAddToDesktopMenu();
		// #endif

		setTimeout(() => {
			uni.getSystemInfo({
				success: (res) => {
					this.width = obj.left || res.windowWidth;
					this.height = obj.top ? obj.top + obj.height + 8 : res.statusBarHeight + 44;
					this.top = obj.top ? obj.top + (obj.height - 32) / 2 : res.statusBarHeight + 6;
					this.scrollH = res.windowWidth;
				}
			});
		}, 0);
	},

	onLoad(options) {
		this.options = options;
		this.getDataList();
	},
	onShow() {
		this.startTime = new Date();
	},
	onHide() {
		if (this.Islogin) {
			// 获取当前页面栈
			const pages = getCurrentPages();
			// 获取当前页面的对象
			const currentPage = pages[pages.length - 1];
			// 获取当前页面的路径
			const route = currentPage.route;
			// 获取当前页面的参数
			const options = currentPage.options;
			this.Microi.ApiEngine.Run('Add_liulanLog', {
				YemianCS: options,
				YemianDZ: route,
				LiulanSJC: new Date().getTime() - this.startTime.getTime()
			});
		}
	},
	onUnload() {
		if (this.Islogin) {
			// 获取当前页面栈
			const pages = getCurrentPages();
			// 获取当前页面的对象
			const currentPage = pages[pages.length - 1];
			// 获取当前页面的路径
			const route = currentPage.route;
			// 获取当前页面的参数
			const options = currentPage.options;
			this.Microi.ApiEngine.Run('Add_liulanLog', {
				YemianCS: options,
				YemianDZ: route,
				LiulanSJC: new Date().getTime() - this.startTime.getTime()
			});
		}
	},
	methods: {
		getWindowHide() {
			var res = uni.getSystemInfoSync();
			this.windowTop = obj.top ? obj.top + (obj.height - 32) / 2 : res.statusBarHeight + 6;
		},
		search() {
			this.page = 1;
			this.noData = false;
			this.getDataList();
		},
		async getDataList() {
			var self = this;
			var res = await self.Microi.ApiEngine.Run('get_Company_GangweiList', {
				Id: self.options.Id,
				page: self.page,
				searchKey: self.searchKey
			});
			if (!res.Data.length) self.noData = true;
			if (self.page == 1) {
				self.DataList = res.Data;
			} else {
				self.DataList.push(...res.Data);
			}
			self.page++;
		},
		getMoreData() {
			if (!this.noData) {
				this.getDataList();
			} else {
				this.Microi.Tips('暂无更多数据', false);
			}
		},
		goBack() {
			if (this.backUrl) {
				uni.reLaunch({
					url: `/pages${this.backUrl}`
				});
			} else {
				let pages = getCurrentPages(); // 获取当前页面堆栈
				let pageCount = pages.length; // 页面堆栈中的页面数量
				// 判断是否有上级页面
				if (pageCount > 1) {
					// 如果有上级页面，则返回上级页面

					uni.navigateBack({
						delta: 1
					});
				} else {
					// 如果没有上级页面，则返回首页
					uni.switchTab({
						url: '/pages/tabbar/find/find' // 替换为你的首页路径
					});
				}
			}
		}
	},
	onReachBottom() {
		this.getMoreData();
	},
	onPullDownRefresh() {
		this.page = 1;
		this.noData = false;
		this.getDataList();

		setTimeout(function () {
			uni.stopPullDownRefresh();
		}, 500);
	}
};
</script>

<style>
	page{
		background-color: #fff;
	}
.container {
	background-color: #fff;
	padding: 175rpx 20rpx 150rpx 20rpx;
	color: #000;
	box-sizing: border-box;
}

.header-box {
	width: 100%;
	position: fixed;
	left: 0;
	top: 0;
	z-index: 999;
	background-color: #fff;
	display: flex;
	align-items: center;
	justify-content: space-between;
	box-sizing: border-box;
}
.header-name {
	font-family: PingFang SC, PingFang SC;
	font-weight: 800;
	font-size: 36rpx;
	color: #181818;
	text-align: center;
	font-style: normal;
	text-transform: none;
}
.header-info {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	gap: 20rpx;
}
.header-btn {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	gap: 20rpx;
}
.header-btn image {
	width: 44rpx;
	height: 44rpx;
}
.hearder-container {
	padding: 20rpx 0;
	border-bottom: 2rpx solid #f4f5f6;
}

.Xinzi-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
}
.xinzi-title {
	font-family: PingFang SC, PingFang SC;
	font-weight: 800;
	font-size: 32rpx;
	color: #333333;
	text-align: left;
	font-style: normal;
	text-transform: none;
}
.right-box {
	font-family: PingFang SC, PingFang SC;
	/* font-weight: 500; */
	font-size: 28rpx;
	color: #999999;
	text-align: center;
	font-style: normal;
	text-transform: none;
}

.xinzi-box {
	width: 690rpx;
	height: 228rpx;
	background: #ffffff;
	border-radius: 16rpx 16rpx 16rpx 16rpx;
	border: 2rpx solid #f4f5f6;
	padding: 22rpx 20rpx;
	box-sizing: border-box;
	margin: 20rpx auto;

	display: flex;
	/* align-items: center; */
	justify-content: space-between;
	flex-direction: column;
}
.xinzi-BT {
	/* width: 158rpx;
	height: 44rpx; */
	font-family: PingFang SC, PingFang SC;
	font-weight: 800;
	font-size: 32rpx;
	color: #333333;
	text-align: left;
	font-style: normal;
	text-transform: none;
}
.xinziinfo-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
}
.Line-info {
	/* 	width: 296rpx;
	height: 40rpx; */
	font-family: PingFang SC, PingFang SC;
	/* font-weight: 500; */
	font-size: 28rpx;
	color: #333333;
	text-align: left;
	font-style: normal;
	text-transform: none;
}
.search-container {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 20rpx;
	margin: 20rpx 0;
}
.search-box {
	width: 590rpx;
	height: 68rpx;
	background: #f4f5f6;
	border-radius: 20rpx 20rpx 20rpx 20rpx;
	padding: 15rpx;
	display: flex;
	align-items: center;
	justify-content: flex-start;
	box-sizing: border-box;
	gap: 10rpx;
}
.search-box image {
	width: 34rpx;
	height: 34rpx;
}
.search-holder {
	/* 
	width: 166rpx;
	height: 40rpx; */
	font-family: PingFang SC, PingFang SC;
	/* font-weight: 500; */
	font-size: 28rpx;
	color: #999999;
	text-align: left;
	font-style: normal;
	text-transform: none;
}
.search-btn {
	font-family: PingFang SC, PingFang SC;
	/* font-weight: 500; */
	font-size: 32rpx;
	color: #666666;
	text-align: left;
	font-style: normal;
	text-transform: none;
}

.no-Data {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-direction: column;
	font-size: 25rpx;
	color: #999999;
	margin: auto;
	margin-top: 200rpx;
}
.no-Data image {
	width: 200rpx;
}
</style>
